package builder.AccountFormBuilderPackage;

import java.awt.Component;

import handler.accountFormHandlers.AccountCancelButtonActionListener;
import handler.accountFormHandlers.AccountUpdateButtonActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;

import builder.FormBuilder;
import builder.FormBuilderDecorator;

import form.FormLabel;
import form.AccountForm.AccountForm;

public class UpdateAccountDecorator extends FormBuilderDecorator{

	public UpdateAccountDecorator(FormBuilder decoratee) {
		super(decoratee);
	}
	
	public void setFormSettings() {
		super.setFormSettings();

	}

	public void buildComponents() {
		super.buildComponents();
		AccountForm accountForm = (AccountForm) decoratee.getForm();
		accountForm.setLayout(new BoxLayout(decoratee.getForm(), BoxLayout.Y_AXIS));
		accountForm.setUserName(new FormLabel("Username: ", new JLabel(), null));	
		buildButtons(accountForm);
	}

	public void buildButtons(AccountForm updateForm){
		
		JButton btnUpdate = new JButton("Update");
		btnUpdate.addActionListener(new AccountUpdateButtonActionListener(updateForm));
		btnUpdate.setAlignmentX(Component.CENTER_ALIGNMENT);
		updateForm.add(btnUpdate);
		
		
		JButton btnCancel = new JButton("Cancel");
		btnCancel.addActionListener(new AccountCancelButtonActionListener(updateForm));
		btnCancel.setAlignmentX(Component.CENTER_ALIGNMENT);
		updateForm.add(btnCancel);

		
	}

}
